<?php

namespace app\admin\controller;
use think\Controller;

class comment extends Controller
{
    /**
     * 显示资源列表
     */
    public function index()
    {
        $page = input('get.page',1);
        $numPage = 2;
        $startPage = ($page-1) * $numPage;
        $count = db('comment')->count();
        $data = db('comment')->limit($startPage,$numPage)->select();
        $pages = ceil(($count/$numPage));
        $this->assign('page',$page);
        $this->assign('pages',$pages);
        $this->assign('count',$count);
        $this->assign('list',$data);
        return view();
    }

    /**
     * 删除指定资源
     */
    public function delete()
    {
        $ids = rtrim(input('post.id/s'),',');
        if(!$ids) return json(['status'=>0,'msg'=>'请选择要删除的角色!']);
        return db('comment')->where('id','IN',$ids)->delete($ids) ? json(['status'=>1,'msg'=>'已删除!']) : json(['status'=>0,'msg'=>'删除失败!']);
    }

}
